home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0920.ZIP / STRING.ARC / READ.ME next >
Text File  |  1987-12-27  |  35KB  |  911 lines

  1.                 Additional Strings Functions and Procedures
  2.  
  3.  
  4. This UNIT contains some additional string functions which for reasons of their
  5. own the wizards at Borland left out of Turbo V4.0. I have found these routines
  6. to be quite useful and decided to implement them as a UNIT.
  7.  
  8. When using these routines you will notice that many of them require a
  9. parameter in the form of SIZEOF(x). I did this so that the assembly routine
  10. which actually performs the function would have the maximum size of the
  11. string variable being used and could therefore check for overflow. Only the
  12. StringOf function does not require this.
  13.  
  14. I have found the Extract type functions most useful in scanning input
  15. parameters. If you do a lot of processing of words they again will prove
  16. quite useful and most efficient as in addition to copying the substring they
  17. also remove it from the source string.
  18.  
  19. All routines are implemented in assembly code for maximum speed. I have
  20. included the assembly source in case you decide you don't like the name of
  21. a routine (often the case with myself) or some such thing.
  22.  
  23. If any errors are found please notify me via the BPROGA forum or via
  24. EASYPLEX. I would also like to hear of any ideas you may have for additional
  25. functions to be included in the future.
  26.  
  27. Happy Programming
  28.  
  29. Jan St Martin
  30.  
  31.  
  32. -----------------------------------------------------------------------------
  33.  
  34.  
  35.  
  36.  
  37.  ExtractForCount
  38.  
  39.    Declaration
  40.        target_str := ExtractForCount(source_string, sizeof(target_string, start_pos)
  41.  
  42.    Operation
  43.        This FUNCTION will move 'n' characters from the source string into the
  44.        target string starting from the character in the source string pointed
  45.        to by start_pos). Once the characters have been moved into the target
  46.        string they are deleted from the source string.
  47.  
  48.   ExtractToChar
  49.  
  50.    Declaration
  51.        target_str := ExtractToChar(source_str, sizeof(target_str), search_char)
  52.  
  53.    Operation
  54.        This FUNCTION will move characters from the source string into the target
  55.        string UNTIL the a character matching search_char is encountered. When
  56.        the search_char is matched character movement stops (movement does not
  57.        include the search_char). The characters that were moved are deleted
  58.        from the source string.
  59.  
  60.   Translate
  61.  
  62.     Declaration
  63.        Translate(str_to_translate, translate_table);
  64.  
  65.     Operation
  66.        This PROCEDURE will translate the string indicated by str_to_translate
  67.        according to the 256 character translation table specified by the
  68.        second operand. The translation table is assumed to be 256 bytes in
  69.        length and must be setup by the caller.
  70.  
  71.        For each byte in the str_to_translate, the character is extracted and
  72.        it's logical value is added to the starting address of the translation
  73.        table. The table character pointed by that sum is used to replace the
  74.        original character.
  75.  
  76.   PadLeft
  77.  
  78.     Declaration
  79.        PadLeft(string, sizeof(string), new_length, pad_char);
  80.  
  81.     Operation
  82.        This PROCEDURE will insert pad_char into the 1st position of string
  83.        until the length of string is equal to new_length or the string
  84.        reaches it's maximum size.
  85.  
  86.  
  87.   PadRight
  88.  
  89.     Declaration
  90.        PadRight(string, sizeof(string), new_length, pad_char);
  91.  
  92.     Operation
  93.        This PROCEDURE will insert pad_char into the LAST position of string
  94.        until the length of string is equal to new_length or the string
  95.        reaches it's maximum size.
  96.  
  97.   Uppercase
  98.  
  99.     Declaration
  100.        target_str := Uppercase (source_str);
  101.  
  102.     Operation
  103.        This FUNCTION will convert each character within the range of a..z in
  104.        the source_string into it's corresponding uppercase character and place
  105.        it into the target_string.
  106.  
  107.   StringOf
  108.  
  109.     Declaration
  110.        target_str := StringOf (pad_char, string_len);
  111.  
  112.     Operation
  113.        This FUNCTION will create a string containing string_len occurances of
  114.        pad_char. The original contents of the string are ignored and the user
  115.        is assumed to know what he/she is doing as there is no check for excedding
  116.        the maximum length of the string.
  117.  
  118.  
  119.  
  120.  
  121.  
  122. Graph unit
  123.   ARTY4    PAS  - Example program for the Graph unit
  124.   GRLINK   PAS  - Example program for the Graph unit that shows how to
  125.                   link font and driver files into an .EXE file.
  126.   DRIVERS  PAS  - Example unit for use with GRLINK.PAS
  127.   FONTS    PAS  - Example unit source for use with GRLINK.PAS
  128.   GRLINK   MAK  - Make file for use with GRLINK.PAS
  129.   MCALC    PAS  - MicroCalc example program
  130.   MC?????? PAS  - Supporting units for MicroCalc
  131.   MCMVSMEM ASM  - Assembler routine used by MicroCalc
  132.   MCMVSMEM OBJ  - Assembled version of MCMVSMEM.ASM
  133.   UNPACK   COM  - Utility to unpack GREXAMPL.ARC
  134.  
  135.   GREXAMPL ARC  - Binary file that contains revised graphics
  136.                   examples from the programs for GRAPH unit.
  137.  
  138.     FILELIST      - List of the example programs in GREXAMPL.ARC
  139.                     and the corresponding procedure/function names
  140.                     and manual page numbers.
  141.     ARC      PAS  - Arc example program
  142.     ARCCOORD PAS  - GetArcCoords example program
  143.     ASPECT   PAS  - GetAspectRatio example program
  144.     BAR      PAS  - Bar example program
  145.     BAR3D    PAS  - Bar3D example program
  146.     CIRCLE   PAS  - Circle example program
  147.     CLOSEGR  PAS  - CloseGraph example program
  148.     CLRDEV   PAS  - ClearDevice example program
  149.     CLRVP    PAS  - ClearViewPort example program
  150.     DETECT   PAS  - DetectGraph example program
  151.     DRPOLY   PAS  - DrawPoly example program
  152.     ELLIPSE  PAS  - Ellipse example program
  153.     FILLPOLY PAS  - FillPoly example program
  154.     FLOOD    PAS  - FloodFill example program
  155.     GETBKCOL PAS  - GetBkColor example program
  156.     GETCOL   PAS  - GetColor example program
  157.     GETFILLS PAS  - GetFillSettings example program
  158.     GETGRMD  PAS  - GetGraphMode example program
  159.     GETLNS   PAS  - GetLineSettings example program
  160.     GETMAXX  PAS  - GetMaxX example program
  161.     GETMAXY  PAS  - GetMaxY example program
  162.     GETPAL   PAS  - GetPalette example program
  163.     GETPIX   PAS  - GetPixel example program
  164.     GETTXTS  PAS  - GetTxtSettings example program
  165.     GETVS    PAS  - GetViewSettings example program
  166.     GETX     PAS  - GetX example program
  167.     GETY     PAS  - GetY example program
  168.     GRERRMSG PAS  - GraphErrorMsg example program
  169.     GRRES    PAS  - GraphResult example program
  170.     IMSIZE   PAS  - ImageSize example program
  171.     INITGR   PAS  - InitGraph example program
  172.     LINE     PAS  - Line example program
  173.     LINEREL  PAS  - LineRel example program
  174.     LINETO   PAS  - LineTo example program
  175.     MOVEREL  PAS  - MoveRel example program
  176.     MOVETO   PAS  - MoveTo example programs
  177.     OUTTXT   PAS  - OutText example program
  178.     OUTTXTXY PAS  - OutTextXY example program
  179.     PIESLICE PAS  - PieSlice example program
  180.     PUTIM    PAS  - PutImage example program
  181.     PUTPIX   PAS  - PutPixel example program
  182.     RECT     PAS  - Rectangle example program
  183.     RESCRT   PAS  - RestoreCrtMode example program
  184.     SETACTPG PAS  - SetActivePage example program
  185.     SETALLP  PAS  - SetAllPalette example program
  186.     SETBKCOL PAS  - SetBkColor example program
  187.     SETCOL   PAS  - SetColor example program
  188.     SETFLPAT PAS  - SetFillPattern example program
  189.     SETGRMOD PAS  - SetGraphMode example program
  190.     SETLNSTY PAS  - SetLineStyle example program
  191.     SETPAL   PAS  - SetPalette example program
  192.     SETTXTJS PAS  - SetTextJustify example program
  193.     SETTXTST PAS  - SetTextStyle example program
  194.     SETVISPG PAS  - SetVisualPage example program
  195.     SETVP    PAS  - SetViewPort example program
  196.     TXTHT    PAS  - TextHeight example program
  197.  
  198.  
  199.  
  200. 2. HOW TO GET HELP
  201. ------------------
  202.   If you need help with Turbo Pascal, please read this file and the
  203.   Reference Manual.
  204.  
  205.   If you still have a question and need technical assistance, help is
  206.   available from the following sources:
  207.  
  208.   1. Type GO BOR on the CompuServe bulletin board system for instant
  209.   access to the Borland forums with their libraries of technical
  210.   information and answers to common questions. In addition, all
  211.   example programs from the manual are available on CompuServe in
  212.   machine-readable form.
  213.  
  214.   If you are not a member of CompuServe, see the enclosed special
  215.   offer, and write for full details on how to receive a free IntroPak
  216.   containing a $15 credit toward your first month's online charges.
  217.  
  218.   2. Check with your local software dealer or users' group.
  219.  
  220.   3. Write to:  Borland International
  221.                 Turbo Pascal Technical Support
  222.                 4585 Scotts Valley Drive
  223.                 Scotts Valley, CA 95066
  224.  
  225.   Please remember to include your serial number or we will be unable
  226.   to process your letter.
  227.  
  228.   4. If you have an urgent problem that cannot wait, you can call the
  229.   Borland Technical Support Department at (408) 438-5300.
  230.  
  231.     Please have the following information ready before calling:
  232.  
  233.     A.  Product name and serial number from your original distribution
  234.         disk. Please have your serial number ready or we will be
  235.         unable to process your call.
  236.  
  237.     B.  Computer brand, model, and the brands and model numbers of any
  238.         additional hardware.
  239.  
  240.     C.  Operating system and version number (the version number can be
  241.         determined by typing VER at the DOS prompt).
  242.  
  243.     D.  Contents of your AUTOEXEC.BAT file.
  244.  
  245.     E.  Contents of your CONFIG.SYS file.
  246.  
  247.  
  248. 3. CORRECTIONS/ADDITIONS TO THE MANUAL
  249. --------------------------------------
  250.  
  251. NOTE:  Important corrections and additions have been made to the
  252.        GRAPH unit documentation.  For the latest information,
  253.        refer to GRAPH.DOC on Disk III.
  254.  
  255.        The file GREXAMPL.ARC on Disk III is a packed file which
  256.        contains example programs for each of the procedures and
  257.        functions in the GRAPH unit. In order to use these files,
  258.        you must first unpack them with UNPACK.COM. The simplest
  259.        way to unpack the graphics examples is to type:
  260.  
  261.          UNPACK GREXAMPL
  262.  
  263.        This will extract all the files from GREXAMPL.ARC and
  264.        place them into the current directory. For a list of other
  265.        options, type UNPACK at the Dos prompt and hit <Enter>.
  266.  
  267. P-14  Correction
  268.   The backward slash (\) in the format command should be a forward
  269.   slash (/): format b: /s
  270.  
  271. P-19  New Help Language Reference Using Ctrl-F1
  272.   More than 150 help screens on Turbo Pascal procedures and functions
  273.   have been added to the online help system. These help topics include
  274.   an introduction to each standard unit, a listing of all the
  275.   constants, types, and variables in each of the standard units, and a
  276.   brief description of every procedure and function described in the
  277.   reference chapter of the Owner's Handbook (extensively
  278.   cross-referenced).
  279.  
  280.   You can access these language topics using the help index, and by
  281.   using the Help lookup editor command (Ctrl-F1). For example, go into
  282.   the editor and type "DiskFree." Then, move the cursor back to the
  283.   beginning of the word and press Ctrl-F1. The following help screen
  284.   will be displayed:
  285.  
  286.     function DiskFree(Drive: word) : longint;
  287.  
  288.     Returns the number of free bytes of a
  289.     specified disk drive.
  290.  
  291.     Unit name Dos
  292.  
  293.     See also  DiskSize, GetDir
  294.  
  295.   If a keyword is not found in the help system, you are given a help
  296.   screen that describes how to use Ctrl-F1. Ctrl-F1 is an editor
  297.   command that can be redefined using TINST (described in Appendix F).
  298.  
  299.   The identifiers referenced under "Unit name" and "See also" are also
  300.   help keywords. This means you can get more help on these items by
  301.   using the cursor control keys and pressing <Enter>.
  302.  
  303. P-20  Using Alt-F1 for Online Help
  304.   Some help screens are now combined into groups, and the PgUp and
  305.   PgDn keys can be used to move around within a help group. In
  306.   addition, the Alt-F1 hot key now remembers groups of screens that
  307.   were previously viewed, rather than each individual screen. Type
  308.   PgUp to travel backward through a help group; type PgDn to go
  309.   forward. A PgUp or PgDn indicator will be present in the lower right
  310.   corner of the help window if you are inside a help group; otherwise,
  311.   the PgUp and PgDn keys have no effect.
  312.  
  313. P-30 The variable ErrorCode in example MYTHIRD.PAS should be changed
  314.   to type integer.
  315.  
  316. P-31   There is a missing less than character (<) in the second While
  317.   statement in the example at the top of the page. The example reads
  318.  
  319.     while Y1 = Finish do
  320.  
  321.   but should read
  322.  
  323.     while Y1 <= Finish do
  324.  
  325.   or else the statement will never be True (since it was initialized
  326.   to Start on the preceding line).
  327.  
  328. P-40 Turbo Pascal predefines a long integer constant, MaxLongInt, with
  329.   a value of 2,147,483,647.
  330.  
  331. P-41  The table at the top of page 41 should look like this:
  332.  
  333.     Type       Range                           Significant     Size in
  334.                                                  Digits         Bytes
  335.     -------------------------------------------------------------------
  336.     real         2.9 X 10E-39 .. 1.7 X 10E38       11-12          6
  337.     single       1.5 X 10E-45 .. 3.4 X 10E38        7-8           4
  338.     double      5.0 X 10E-324 .. 1.7 X 10E308      15-16          8
  339.     extended   1.9 X 10E-4951 .. 1.1 X 10E4932     19-20         10
  340.     comp            -2E+63 +1 .. 2E+63 -1          19-20          8
  341.  
  342. P-63  Interface Section
  343.   If the procedure (or function) is external, the keyword external
  344.   may only appear in the IMPLEMENTATION section.
  345.  
  346. P-123  Input and Output
  347.   In version 3.0, you could call the procedure CLOSE on a file that
  348.   was already closed with no results. In version 4.0, it produces an
  349.   I/O error, which you can trap by disabling I/O error checking (via
  350.   the {$I-} option) and testing the value returned by IOResult.
  351.  
  352. P-125  Compiler Directives and Error-Checking
  353.   The {$I} include file directive is no longer allowed between a
  354.   begin/end pair. In addition, an include file directive must always
  355.   have a space between the "I" and the filename.
  356.  
  357. P-126  Assembly Language Usage
  358.   Inline/external procedures and functions that used byte value
  359.   parameters in version 3.0 often took advantage of the fact that the
  360.   high byte of the word pushed on the stack was initialized to 0. In
  361.   version 4.0 this initialization is not done so you will need to
  362.   check inline/external routines to make sure they don't assume that
  363.   the high byte is 0.
  364.  
  365. P-135  New TPMAP Options
  366.   In addition to converting a .TPM file to a .MAP file, the TPMAP
  367.   program now also produces a text file that contains a complete list
  368.   of all units, include files and .OBJ files used by the Turbo Pascal
  369.   program.
  370.  
  371.   For example, given a file named TEST.PAS:
  372.  
  373.     program Test;
  374.     uses Crt;
  375.     begin
  376.       ClrScr;
  377.       Write('Turbo Pascal');
  378.     end.
  379.  
  380.   then the commands
  381.  
  382.     tpc test /$t+
  383.     tpmap test
  384.  
  385.   will (1) compile TEST.EXE and produce a TEST.TPM file and (2)
  386.   generate TEST.MAP and TEST.DEP.
  387.  
  388.   Here's a dump of TEST.DEP:
  389.  
  390.     program TEST in TEST.PAS;
  391.     uses
  392.       Crt;
  393.  
  394.     unit Crt in CRT.PAS;
  395.     Links
  396.       CRT.OBJ;
  397.  
  398.   As you can see, the listing contains the module names (TEST, CRT),
  399.   the corresponding file names (TEST.PAS and CRT.PAS), and a list of
  400.   .OBJ files linked in using the {$L} compiler directive (CRT.OBJ).
  401.   TPMAP will only produce a .MAP file if you use the /M command line
  402.   option. Similarly, the /D option will only produce a .DEP file.
  403.  
  404. P-148  Under the "Bottom Line" section, the bottom line only changes
  405.   when you hold down the Alt key.
  406.  
  407. P-148  Inserting Compiler Directives into the Editor
  408.   A new editor command, Ctrl-F7, expands the integrated environment's
  409.   compiler directive settings into text and inserts them at the
  410.   beginning of the current edit file. Try loading a file into the
  411.   editor and pressing Ctrl-F7. If you haven't changed any of the
  412.   default switch settings on the Options/Compiler menu, the following
  413.   text will be inserted at the top of the file in the editor:
  414.  
  415.     {$R-,S+,I+,D+,T-,F-,V+,B-,N-,L+ }
  416.     {$M 16384,0,655360 }
  417.  
  418.   These are all the options found on the Options/Compiler and Memory
  419.   sizes menus. In addition, any conditional defines from the
  420.   Options/Compiler/Conditional defines menu item would have been
  421.   inserted as {$DEFINE xxxx } directives.
  422.  
  423. P-153  First Letter Movement with Directory Windows
  424.   You can now move through the directory box by using first letter
  425.   selection. Pressing the <B> key, for example, takes you to the first
  426.   file name starting with "B." Pressing <B> again takes you to the
  427.   next file name, and so on. If there are no other file names
  428.   beginning with the letter "B," you will be taken back to the first
  429.   one. If no file names start with the letter "B," then the cursor
  430.   will not move. Holding down the <Shift> key and pressing <B> will
  431.   take you to the first subdirectory that begins with the letter "B."
  432.  
  433. P-158  Disregard the last sentence in the paragraph at the top of the
  434.   page. Compiler options are discussed in the following section. There
  435.   is no Chapter C.
  436.  
  437. P-170  Pair braces commands (Editor Commands)
  438.   Here are the correct commands for Pair braces forward and Pair
  439.   braces backward:
  440.  
  441.     Pair braces forward    Ctrl-Q [
  442.     Pair braces backward   Ctrl-Q ]
  443.  
  444. P-170  New Editor Commands
  445.   The following commands should be added to the table:
  446.  
  447.     Language help                      Ctrl-F1
  448.     Insert compiler directives         Ctrl-F7
  449.  
  450.   Refer to the P-19 and P-148 README notes above for details.
  451.  
  452. P-184  Quiet Mode Compiler Option
  453.   A quiet mode option has been added to the command-line compiler.
  454.   With the default switches, TPC will display the file name and line
  455.   number of the program module currently being compiled. Using the
  456.   quiet option:
  457.  
  458.     TPC mystuff /Q
  459.  
  460.   will suppress the printing of file names and line numbers during the
  461.   compilation. Normally, TPC reports elapsed compilation time based on
  462.   the IBM PC's internal timer. On generic MS-DOS machines using the /Q
  463.   option, the current file name and line number is only updated when
  464.   files are opened and closed, and the compiler does not calculate the
  465.   elapsed time.
  466.  
  467. P-191  Add a paragraph to the description of the /R option
  468.   for TPC:
  469.  
  470.     If you need to pass multiple parameters to a program when using
  471.     the /R option, enclose ALL of the parameters in double quotes.
  472.     Note that the first double quote must be the character immediately
  473.     following the R in the /R option (no spaces in between). You can
  474.     embed slashes and dashes in your parameter line:
  475.  
  476.       tpc mystuff /m /r"file1/a file2/b -2"
  477.  
  478.     In this case, three parameters would be passed to program mystuff:
  479.     file1/a, file2/b and -2.
  480.  
  481. P-192  The /x option in the example command at the bottom of
  482.   this page should be changed to /r.
  483.  
  484. P-229  Variable Typecasts: High-Word/Low-Word Example
  485.   The built-in functions Hi and Lo return the high- and low-order
  486.   bytes of a word or integer variable. To determine the high- and
  487.   low-order words of a long integer variable, you should use a
  488.   variable typecast:
  489.  
  490.     type
  491.       WordRec = record                 { used for typecast }
  492.           Low, High : word;
  493.         end;
  494.     var
  495.       L : longint;
  496.     begin
  497.       L := $10000;                     { 65536 decimal }
  498.       Writeln(WordRec(L).Low);         { 0 }
  499.       Writeln(WordRec(L).High);        { 1 }
  500.     end.
  501.  
  502.   Similarly, here's an inexpensive (code-wise) alternative to the Seg
  503.   and Ofs functions:
  504.  
  505.     type
  506.       PtrRec = record                  { used for typecast }
  507.           Ofs, Seg : word;
  508.         end;
  509.     var
  510.       P : pointer;
  511.     begin
  512.       P := Ptr($1234, $4567);
  513.       Writeln(PtrRec(P).Ofs);          { $4567 }
  514.       Writeln(PtrRec(P).Seg);          { $1234 }
  515.     end.
  516.  
  517.   In this example, using a variable typecast generates less code and
  518.   is faster than using the standard functions Seg and Ofs.
  519.  
  520. P-278  Units That Use Other Units
  521.   The uses clause in a program or unit may--but does NOT have to--name
  522.   all units used directly or indirectly. In the example at the top of
  523.   the page, the uses statement of program Host can be written in
  524.   several ways:
  525.  
  526.     uses Unit1, Unit2; - The identifiers in the interface sections of
  527.                          both units may be referenced in program Host.
  528.  
  529.     uses Unit2;        - Only the identifiers in the interface section
  530.                          of Unit2 may be referenced in program Host.
  531.  
  532.   In the second example, the compiler will recursively analyze unit
  533.   dependencies and will correctly determine that Unit2 is dependent on
  534.   Unit1, and that program Host is dependent on both. Note that none of
  535.   the identifiers declared in the interface section of Unit1 are
  536.   available to Host because it does not use Unit1 explicitly.
  537.  
  538. P-280  FileMode Variable
  539.   The FileMode variable defined by the System unit determines the
  540.   access code passed DOS when typed and untyped files (not text files)
  541.   are opened using the Reset procedure.
  542.  
  543.   The default FileMode is 2, which allows both reading and writing.
  544.   Assigning another value to FileMode causes all subsequent Resets to
  545.   use that mode.
  546.  
  547.   The range of valid FileMode values depends on the version of DOS in
  548.   use. However, for all versions, the following modes are defined:
  549.  
  550.     0  -  Read only.
  551.     1  -  Write only.
  552.     2  -  Read/Write.
  553.  
  554.   DOS versions 3.x define additional modes, which are primarily
  555.   concerned with file-sharing on networks. For further details on
  556.   these, please refer to your DOS Programmer's Reference manual.
  557.  
  558.   Note: New files created using Rewrite are always opened in
  559.   Read/Write mode, corresponding to FileMode=2.
  560.  
  561. P-296  System Unit Traps Interrupt 24: SaveInt24
  562.   The system unit contains an INT 24 handler for trapping critical
  563.   errors. When running an .EXE program created by Turbo Pascal, a DOS
  564.   critical error will be treated like any other I/O error: the program
  565.   counter and an error number will display and the program will
  566.   terminate. Disk errors are detectable by using {$I-} and checking
  567.   IOResult.
  568.  
  569.   The original INT 24 vector is saved in a pointer variable in the
  570.   System unit (SaveInt24). Here's a simple program that re-installs
  571.   the original vector:
  572.  
  573.     program Restore;
  574.     uses Dos;
  575.     begin
  576.       SetIntVec($24, SaveInt24);      { restore original vector }
  577.       ...
  578.     end.
  579.  
  580. P-298, 355  TextRec Record
  581.   Here is the TextRec as it is actually declared in the Dos unit:
  582.  
  583.     { Textfile record }
  584.     TextBuf = array[0..127] of char;
  585.     TextRec = record
  586.         Handle: word;
  587.         Mode: word;
  588.         BufSize: word;
  589.         Private: word;
  590.         BufPos: word;
  591.         BufEnd: word;
  592.         BufPtr: ^TextBuf;
  593.         OpenFunc: pointer;
  594.         InOutFunc: pointer;
  595.         FlushFunc: pointer;
  596.         CloseFunc: pointer;
  597.         UserData: array[1..16] of byte;
  598.         Name: array[0..79] of char;
  599.         Buffer: TextBuf;
  600.       end;
  601.  
  602. P-304, 494, 511  TextMode procedure: LastMode and Font8x8
  603.   The Mode parameter is of type word. Here is the actual TextMode
  604.   declaration from the Crt unit:
  605.  
  606.     procedure TextMode(Mode: word);
  607.  
  608.   In addition, the Last constant described in the manual is now a word
  609.   variable in the Crt unit and has been renamed to LastMode. Each time
  610.   TextMode is called, the current video mode is stored in LastMode. In
  611.   addition, LastMode is initialized at program startup to the
  612.   then-active video mode.
  613.  
  614.   A new constant is now defined in Crt:
  615.  
  616.     const
  617.       Font8x8 = $100;
  618.  
  619.   and the TextMode procedure supports 43-line mode on an EGA and
  620.   50-line mode on a VGA. The following call to TextMode:
  621.  
  622.     TextMode(CO80 + Font8x8)
  623.  
  624.   will reset the display into 43 lines and 80 columns on an EGA, or 50
  625.   lines and 80 columns on a VGA with a color monitor.
  626.   TextMode(Lo(LastMode)) always turns off 43- or 50-line mode and
  627.   resets the display (although it leaves the video mode unchanged);
  628.   while TextMode(Lo(LastMode) + Font8x8) will keep the video mode the
  629.   same, but reset the display into 43 or 50 lines.
  630.  
  631.   If your system is in 43- or 50-line mode when you load a Turbo
  632.   Pascal program, the mode will be preserved by the Crt startup code
  633.   and the window variable that keeps track of the maximum number of
  634.   lines on the screen (WindMax) will be initialized correctly.
  635.  
  636. P-308, 322, 465  RestoreCrt procedure
  637.    Instead of the RestoreCrt procedure, the Crt unit contains a
  638.    word variable, LastMode, that can be used to restore the video
  639.    mode detected at program startup. When execution begins, Crt stores
  640.    the then-active video mode in LastMode. In addition, each time
  641.    TextMode is used to change video modes, the current mode is stored
  642.    in LastMode. Here's how to write a "well-behaved" program that will
  643.    restore the video mode to its original state:
  644.  
  645.      program Video;
  646.      uses Crt;
  647.      var
  648.        OrigMode : word;
  649.      begin
  650.        OrigMode := LastMode;      { remember original mode }
  651.        ...
  652.        TextMode(OrigMode);
  653.      end.
  654.  
  655.   Note that TextMode does not support graphics modes, and therefore
  656.   TextMode(OrigMode) will only restore those modes supported by
  657.   TextMode. For more information on LastMode and TextMode, refer to
  658.   the P-304 README notes above.
  659.  
  660. P-337  Use of the 8087 within OBJ Files
  661.   The use of 8087 instructions from object code linked in from .OBJ
  662.   files is not detected by Turbo Pascal. If you link with an .OBJ file
  663.   that uses the math coprocessor, the .OBJ must do its own
  664.   initialization and error-checking.
  665.  
  666. P-340  The default maximum heap memory size is 640 K-bytes.
  667.  
  668. P-347  MyGetMem
  669.   To conform with the description in the text, procedure MyGetMem
  670.   should be renamed to GetMem, and a FreeMem routine should be added.
  671.   The two procedures should look like this:
  672.  
  673.     procedure GetMem(var P : pointer; Size : word);
  674.     begin
  675.       System.GetMem(P, (Size + 15) and $FFF0);  { 16 byte blocks }
  676.     end;
  677.  
  678.     procedure FreeMem(var P : pointer; Size : word);
  679.     begin
  680.       System.FreeMem(P, (Size + 15) and $FFF0);  { 16 byte blocks }
  681.     end;
  682.  
  683. P-358  Calling Conventions and Nested Procedures and Functions
  684.   A procedure or function is said to be nested when it is declared
  685.   within another procedure or function. Nested procedures and
  686.   functions always use the NEAR call model, regardless of the setting
  687.   of the {$F} compiler switch, since they are only "visible" within a
  688.   specific procedure or function in the same code segment.
  689.  
  690.   When calling a nested procedure or function, the compiler generates
  691.   a PUSH BP instruction just before the CALL, in effect passing the
  692.   caller's BP as an additional parameter. Once the called procedure
  693.   has set up its own BP, the caller's BP is accessible as a word
  694.   stored at [BP+4]. Using this "link" at [BP+4], the called procedure
  695.   can access the local variables in the caller's stack frame. If the
  696.   caller itself is also a nested procedure, it also has a link at
  697.   [BP+4], and so on. The following example demonstrates how to access
  698.   local variables from an inline statement in a nested procedure:
  699.  
  700.     procedure A;
  701.     var IntA: Integer;
  702.     procedure B;
  703.     var IntB: Integer;
  704.     procedure C;
  705.     var IntC: Integer;
  706.     begin inline(
  707.       $8B/$46/<IntC/      { MOV  AX,IntC[BP]     ; AX = IntA             }
  708.       $8B/$5E/$04/        { MOV  BX,[BP+4]       ; BX = B's stack frame  }
  709.       $36/$8B/$47/<IntB/  { MOV  AX,SS:IntB[BX]  ; AX = IntB             }
  710.       $8B/$5E/$04/        { MOV  BX,[BP+4]       ; BX = B's stack frame  }
  711.       $36/$8B/$5F/$04/    { MOV  BX,SS:[BX+4]    ; BX = C's stack frame  }
  712.       $36/$8B/$47/<IntA); { MOV  AX,SS:IntA[BX]  ; AX = IntA             }
  713.     end {C};
  714.     begin {B}
  715.     end {B};
  716.     begin {A}
  717.     end {A};
  718.  
  719.   Note: Nested procedures and functions cannot be declared with the
  720.   external directive.
  721.  
  722. P-367  The comments are backward in the inline example on this page.
  723.   POP AX comes first, followed by POP DX.
  724.  
  725.     function LongMul(X,Y : integer) : longint;
  726.     inline(
  727.       $58/            { POP AX    ; Pop Y       }
  728.       $5A/            { POP DX    ; Pop X       }
  729.       $F7/$EA);       { IMUL DX   ; DX:AX = X*Y }
  730.  
  731. P-373  Example Unit: Unit AuxInOut
  732.   The example shown at the bottom of the page is incorrect. The
  733.   correct example is in a file named AUXINOUT.PAS on Disk II.
  734.  
  735. P-402  Add the following paragraph to the description of the Eoln
  736.   function:
  737.  
  738.     When checking Eoln on standard input that has not been redirected,
  739.     the following program will wait for a carriage return to be
  740.     entered before returning from the call to Eoln:
  741.  
  742.     begin
  743.       Writeln(Eoln);  { This call to Eoln will cause the program
  744.                         to wait for keyboard input }
  745.     end.
  746.  
  747. P-415  The Declaration for the GetFAttr procedure is
  748.  
  749.     procedure GetFAttr(var f; var Attr : word);
  750.  
  751. P-497  Range-Checking With Val
  752.   The standard procedure Val, which converts a string's contents to a
  753.   numeric variable, performs range-checking differently depending on
  754.   the state of {$R} and the type of the parameter V:
  755.  
  756.     Val(s : string; var V; var Code : integer);
  757.  
  758.   With range-checking on, {$R+}, an out-of-range value always
  759.   generates a runtime error. With range-checking off, {$R-}, the
  760.   values for an out-of-range value vary depending upon the data type
  761.   of V. If V is a real or longint type, the value of V is undefined
  762.   and Code returns a non-zero value. For any other numeric type, Code
  763.   returns a value of zero and V will contain the results of an
  764.   overflow calculation (assuming the string value is within the long
  765.   integer range).
  766.  
  767.   Therefore, you should pass Val a longint variable and perform
  768.   range-checking before making an assignment of the returned value:
  769.  
  770.     {$R-}
  771.     Val('65536', LongIntVar, Code)
  772.     if (Code <> 0) or
  773.        (LongIntVar < 0) or (LongIntVar > 65535) then
  774.        ...                                             { error }
  775.     else
  776.       WordVar := LongIntVar;
  777.  
  778.   In this example, LongIntVar would be set to 65536 and Code would
  779.   equal 0. Because 65536 is out of range for a word variable, an error
  780.   would be reported.
  781.  
  782.   In addition, Val has been modified to ignore leading spaces.
  783.  
  784. P-417  GetFTime
  785.   The type was omitted from the 2nd parameter. The correct declaration
  786.   for GetFTime is
  787.  
  788.     procedure GetFTime(var F; var Time: longint);
  789.  
  790. P-448  MsDos procedure
  791.   The MsDos procedure is incorrectly labeled a function. Here's the
  792.   actual declaration as it appears in the Dos unit:
  793.  
  794.     procedure MsDos(var Regs : Registers);
  795.  
  796. P-493  Crt Color Constants
  797.   There are 16 foreground color constants:
  798.  
  799.     const
  800.       Black         = 0;
  801.       Blue          = 1;
  802.       Green         = 2;
  803.       Cyan          = 3;
  804.       Red           = 4;
  805.       Magenta       = 5;
  806.       Brown         = 6;
  807.       LightGray     = 7;
  808.       DarkGray      = 8;
  809.       LightBlue     = 9;
  810.       LightGreen    = 10;
  811.       LightCyan     = 11;
  812.       LightRed      = 12;
  813.       LightMagenta  = 13;
  814.       Yellow        = 14;
  815.       White         = 15;
  816.  
  817.       { Add-in for blinking }
  818.       Blink         = 128;
  819.  
  820. P-499  Window
  821.   A call to the Window procedure always moves the cursor to (1,1).
  822.  
  823. P-510  Differences from 3.0: MemW, FileSize
  824.   In version 3.0, MemW returned an integer value. In version 4.0, it
  825.   returns a value of type word. In 4.0, Filesize of an untyped file
  826.   will ignore a partial block when the block size is greater than 1.
  827.  
  828. P-523  Standard Procedures and Functions
  829.   In the list provided, two entries are combined into one:
  830.  
  831.     FillChar
  832.     Frac
  833.  
  834. P-529  Force Far Calls Compiler Directive
  835.   The {$F} (force far calls) compiler directive has no effect on a
  836.   nested procedure. The nested procedure always uses the near call
  837.   model.
  838.  
  839. P-565  New Utility Program: BINOBJ.EXE
  840.   A utility program BINOBJ.EXE has been added that converts any file
  841.   to an .OBJ file so it can be linked into a Turbo Pascal program as a
  842.   "procedure." Refer to BINOBJ.DOC on Disk II for more information on
  843.   this new utility.
  844.  
  845. P-570  The second paragraph on this page should be replaced with the
  846.   following:
  847.  
  848.     See the description of the ReadKey function on page 461 for a
  849.     description of how to determine if an extended key (function key
  850.     or cursor movement key) has been pressed.
  851.  
  852. P-586  Automatic Compaq Detection Override
  853.   The integrated environment will detect whether you are using a
  854.   Compaq computer and automatically use its black and white color set.
  855.   This gives better contrast on the composite monitors that are
  856.   built-in to the vast majority of Compaq computers. If you are using
  857.   a Compaq computer and a true color monitor, you can force the
  858.   integrated environment to use its color tables by running TINST,
  859.   typing "D" to install the Display mode, and selecting Color.
  860.  
  861. P-619 to 630  New Error Messages
  862.  
  863.   COMPILER ERROR MESSAGES:
  864.  
  865.      68  Circular unit reference
  866.       Two units are not allowed to use each other:
  867.  
  868.          unit U1;           unit U2;
  869.          uses U2;           uses U1;
  870.          ...                ...
  871.  
  872.       In this example, doing a Make on either unit will
  873.       generate error 68.
  874.  
  875.     132  Critical disk error
  876.       A critical error occurred during compilation (e.g. drive not
  877.       ready error).
  878.  
  879.     133  Old map file
  880.       The .TPM file is older than the corresponding .EXE file. It's an
  881.       indication that the last time you compiled your program, a .TPM
  882.       file was not produced. For example, if TEST.TPM is older than
  883.       TEST.EXE, to find a runtime error you must recompile TEST.PAS
  884.       with the {$T} compiler directive on.
  885.  
  886.   RUNTIME ERROR MESSAGES: Critical Errors
  887.  
  888.     Runtime errors fall into four categories: DOS errors (1-99),
  889.     I/O errors (100-149), critical errors (150-199), fatal errors
  890.     (200-249).
  891.  
  892.     The following critical error messages have been added since the
  893.     manual was printed:
  894.  
  895.       150  Disk is write-protected
  896.       151  Unknown unit
  897.       152  Drive not ready
  898.       153  Unknown command
  899.       154  CRC error in data
  900.       155  Bad drive request structure length
  901.       156  Disk seek error
  902.       157  Unknown media type
  903.       158  Sector not found
  904.       159  Printer out of paper
  905.       160  Device write fault
  906.       161  Device read fault
  907.       162  Hardware failure
  908.  
  909.     Refer to your DOS programmer's reference manual for more
  910.     information about critical errors.
  911.